/*
 * ibdtrace.h
 *
 *  Created on: Sep 20, 2011
 *      Author: lindenb
 */

#ifndef IBDTRACE_H_
#define IBDTRACE_H_
#include <vector>
#include "bdbibd.h"
#include "postscript.h"




class ApplicationTracer:public ApplicationReader
	{
	public:
		typedef Postscript::pixel_t pixel_t;
	protected:

		struct PositionXY
			{
			position_t position;
			pvalue_t pvalue;
			};


		struct ChromInfo
			{
			tid_t chrom;
			position_t minPos;
			position_t maxPos;
			float fraction;
			pixel_t width;
			pixel_t x;
			position_t length() const
				{
				return maxPos-minPos;
				}
			};

		struct PairInfo
			{
			pair_id_t pair_id;
			individual_id_t other;
			int index;
			pixel_t y;
			std::vector<PositionXY>* data;
			/** extra pair info that will be used as a digest of the others (common peaks...) */
			bool flag_is_digest;
			};



		int64_t genome_size;
		std::vector<ChromInfo> chromInfos;
		pixel_t pair_height;
		pixel_t pair_margin_y;
		pixel_t x_axis_width;
		pixel_t margin_left;
		pixel_t margin_right;
		pixel_t margin_top;
		pixel_t margin_bottom;
		Postscript* PS;

		void buildChromInfo();
		void finalizeChromInfo();
		void buildIndividual(const Individual* indi);
	public:
		ApplicationTracer();
		virtual ~ApplicationTracer();
		virtual void usage(std::ostream& out);
		virtual int main(int argc,char** argv);
	};

#endif /* IBDTRACE_H_ */
